package hc.bre.clas.abtest

import hc.bre.ComponentConfig
import hc.bre.clas.ClasRuleDefinition
import hc.bre.clas.branch.BranchDefinition
import hc.bre.clas.range.RangeDefinition
import hc.bre.clas.range.RangeOption

@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true,includePackage=false)
class AbtestDefinition extends ClasRuleDefinition<RangeOption>{
	public static final ComponentConfig _config ;
	static {
		_config = new ComponentConfig();
		_config.rtype = 'rule:clas:abtest';
		_config.rname = 'AB TEST分发';
		_config.builderClass = AbtestBuilder;
		_config.resultStruct = new hc.bre.clas.ClasResultStruct();
		_config.objectpage = '/rule/clas/AbtestEditor.htm?rpath=${rpath}';
		_config.description = '''AB TEST基于随机数或者某一变量执行不同分支，用户流量分发和对比测试。''';
	}
	
	public static AbtestDefinition create() {
		def ruleDef = new AbtestDefinition();
		ruleDef.list = [
			new RangeOption().load([id:0,code:'other',name:'其它',range:'{true}',otherflag:1])
		];
		ruleDef.variableId = -1;
		return ruleDef;
	}

	Integer variableId;

	@Override
	public AbtestDefinition load(Map map) {
		super.load(map);
		variableId = map['variableId'] as Integer;
		return this;
	}
}
